package com.easychat.common;

import com.easychat.enums.ExceptionCodeEnum;

/**
 * @author 10 2024/10/4
 */
public class LeaseException extends RuntimeException{
    //异常状态码
    private Integer code;

    /**
     * 通过状态码和错误消息创建异常对象
     * @param message
     * @param code
     */
    public LeaseException(String message,Integer code){
        super(message);
        this.code = code;
    }

    /**
     * 根据响应结果枚举对象创建异常
     * @param
     */
    public LeaseException(ExceptionCodeEnum exceptionCodeEnum){
        super(exceptionCodeEnum.getMessage());
        this.code = exceptionCodeEnum.getCode();
    }
    public LeaseException(String message){
        super(message);
    }


    @Override
    public String toString() {
        return "LeaseException{" +
                "code=" + code +
                ", message=" + this.getMessage() +
                '}';
    }
}
